package com.abocode.aichat.server.stanza;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by franky-18.
 */
public class StanzaWrapper {

    private final static int offline_code=201;
    private final static int online_code=200;
    private final static int success_code=200;

    public final static Stanza wrapper(String id, String namespace, String module, Map body) {
        return new StanzaImpl(id, body, namespace, module);
    }

    public final static Stanza wrapper(Stanza stanza, Map body) {
        return new StanzaImpl(stanza.id(), body, stanza.namespace(), stanza.module());
    }

    public final static Stanza wrapperSuccess(Stanza stanza) {
        return new StanzaImpl(stanza.id(), success(success_code), stanza.namespace(), stanza.module());
    }

    public final static Stanza wrapperOffline(Stanza stanza) {
        return new StanzaImpl(stanza.id(), success(offline_code), stanza.namespace(), stanza.module());
    }
    public final static Stanza wrapper(Stanza stanza,int code ) {
        return new StanzaImpl(stanza.id(), success(code), stanza.namespace(), stanza.module());
    }

    public final static Stanza wrapperOnline(Stanza stanza) {
        return new StanzaImpl(stanza.id(), success(online_code), stanza.namespace(), stanza.module());
    }

    public final static Map success(Integer code) {
        Map map = new HashMap();
        map.put("status", code);
        return map;
    }
}
